package com.stone.serviceimpl;

import java.util.List;

import com.stone.daoimpl.ProviderDao;
import com.stone.daoimpl.ProviderStoneDao;
import com.stone.model.ProviderStone;
import com.stone.service.IProviderStoneService;
import com.stone.utils.Page;

public class ProviderStoneService implements IProviderStoneService {
	
	private ProviderStoneDao providerStoneDao;
	private ProviderDao providerDao;
	
	//----set and get
	
	public ProviderStoneDao getProviderStoneDao() {
		return providerStoneDao;
	}

	public void setProviderStoneDao(ProviderStoneDao providerStoneDao) {
		this.providerStoneDao = providerStoneDao;
	}
	
	public ProviderDao getProviderDao() {
		return providerDao;
	}

	public void setProviderDao(ProviderDao providerDao) {
		this.providerDao = providerDao;
	}

	//-----implements functions
	
	public ProviderStone addProviderStone(ProviderStone ps) {
		return providerStoneDao.save(ps);
	}
	
	public List<ProviderStone> findAllPrividerStoneByProviderId(Long providerId) {
		return providerStoneDao.findByProperty("provider", providerDao.findById(providerId));
	}

	public void deleteProviderStone(ProviderStone ps) {
		providerStoneDao.delete(ps);
	}

	public void updateProviderStone(ProviderStone ps) {
		 providerStoneDao.update(ps);
	}

	public Page findAllPrividerStoneByProviderIdByPage(Long providerId,
			int pageno, int pagesize) {
		return providerStoneDao.findAllPrividerStoneByProviderIdByPage(providerDao.findById(providerId), pageno, pagesize);
	}
	
	public Page findDisplayAllProviderStoneByProviderIdByPage(Long providerId, int pageno, int pagesize)
	{
		return providerStoneDao.findAllDisplayProviderStonesByProviderIdByPage(providerDao.findById(providerId), pageno, pagesize);
	}
	
}
